1. Field of the Invention
The present invention relates to a data recovery apparatus and method used for a flash memory, and more particularly, to a data recovery apparatus and method used for a flash memory, which can recover data damaged or lost when power supplied to the flash memory is cut off while data operations are being consecutively performed on at least one data stored in the flash memory.
2. Description of the Related Art
In general, home appliances, communications devices, and embedded systems, such as set-top boxes, use non-volatile memories as storage devices for storing and processing data.
Among such non-volatile memories, flash memories are electrically-erasable and rewritable memories. Flash memories are suitable for portable devices because they consume less power than magnetic disc memory-based storage mediums, are as accessible as hard discs, and are compact-sized.
Due to the hardware characteristics of flash memories, data recorded on a flash memory should be erased before data is overwritten on the flash memory.
A unit in which data is recorded on a flash memory may differ from a unit in which data is erased from the flash memory, which may result in deterioration of the performance of the flash memory.
In order to prevent the performance of the flash memory from deteriorating for this reason, logical addresses and physical addresses have been suggested.
Here, logical addresses are virtual addresses specified by a user when executing a data operation on the flash memory using a program. By comparison, physical addresses are actual addresses referenced when executing the data operation on the flash memory.
Flash memory is generally classified into either a small block flash memory or a large block flash memory. In a small block flash memory, a logical operation unit is equal to a physical operation unit, whereas in a large block flash memory, a logical operation unit is smaller than a physical operation unit.
FIGS. 1A and 1B are schematic diagrams illustrating a small block flash memory and a large block flash memory, respectively.
Referring to FIG. 1A, logical computations of the small block flash memory are performed in units of a sector 11, and physical computations of the small block flash memory are performed in units of a page 12, which is as large as sector 11.
Referring to FIG. 1B, logical computations of the large block flash memory are performed in units of a sector 21, and physical computations of the large block flash memory are performed in units of a page 22, which is comprised of at least one sector 21.
In general, flash memory-based systems are comprised of a CPU and non-volatile memories, such as RAMs.
Here, the flash memory-based system may unexpectedly suffer from frequent power interruptions due to its characteristics.
Therefore, the flash memory-based system needs a function of recovering data damaged or lost due to a power interruption.
Specifically, when the power supplied to the flash memory-based system is cut off while data is being written to a flash memory in the flash memory-based system, some of the data may be successfully written to the flash memory, but the rest of the data may not.
Therefore, various methods to determine whether data written to a flash memory is complete have been suggested.
Of those methods, a method in which marks are used to indicate whether a data operation performed on a flash memory is complete will now be described more fully with reference to FIG. 2.
FIG. 2 is a flowchart of a conventional data recovery method used for a flash memory. Referring to FIG. 2, in operation S21, a data operation is performed at a predetermined logical address on a flash memory. In operation S22, if the data operation is complete, a mark indicating that the data operation performed at the predetermined logical address is complete is written to a predetermined area of the flash memory.
In other words, as shown in FIG. 3, if the flash memory is a small block flash memory, it may include a data area 31, in which a data computation is executed, and an index area 32, which indicates, with the use of marks, whether the data computation executed in the data area 31 is complete.
Like the small block flash memory, the large block flash memory may also have a data area and an index area.
In this case, if the data area 31 and the index area 32 are located in the same block of the flash memory, and a data erasure operation is performed on the block of the flash memory where the data area 31 and the index area 32 are located, the data area 31 and the index area 32 are all set to a value of 1.
In addition, if the data operation is performed on the data area 31 and the performance of the data operation is complete, the index area 32 is switched from 1 to 0 to indicate completion of the data operation on the block of the flash memory where the data area 31 and the index area 32 are located.
In operation S23, it is determined whether the data operation has already been performed at each of a plurality of consecutive logical addresses of the flash memory. In operation S24, if there are logical addresses that have not yet undergone the data operation, the data operation is performed at a logical address subsequent to the predetermined logical address, and then the method returns to operation S22.
When the data operation has been performed for all of the logical addresses of the flash memory, the flash memory may undergo a data validity test, which will now be described more fully with reference to FIG. 4.
In operation S41, a value of the index area 32 is identified. In operation S42, it is determined, based on the value of the index area 32, whether a data operation performed at a corresponding logical address is valid.
For example, if the value of the index area 32 is 0, the data computation performed at the corresponding logical address is determined valid. If the value of the index area 32 is 1, the data computation performed at the corresponding logical address is determined invalid.
However, according to conventional data recovery methods used for a flash memory, whenever a data operation is performed on the flash memory, a mark value indicating whether the data operation was successful should be recorded in a corresponding index area on the flash memory.
For example, if the data operation is sequentially performed in six data areas, the mark value should be sequentially recorded in index areas corresponding to the six data areas, which adds up to a total of twelve data computation operations.
Therefore, the conventional data recovery methods may undesirably increase the amount of data computation, thus deteriorating the performance of the flash memory.